package cn.dujc.superkid.adapter;

import android.support.annotation.Nullable;

import java.util.List;

import cn.dujc.core.adapter.BaseAdapter;
import cn.dujc.core.adapter.BaseViewHolder;
import cn.dujc.core.adapter.util.MultiTypeDelegate;
import cn.dujc.superkid.R;
import cn.dujc.superkid.bean.CupListResult;

public class MatchDetailAdapter extends BaseAdapter<Object> {
    public MatchDetailAdapter(@Nullable List<Object> data) {
        super(data);
        final MultiTypeDelegate<Object> delegate = new MultiTypeDelegate<Object>() {
            @Override
            protected int getItemType(Object o) {
                return o instanceof String ? R.layout.item_subtitle_text : R.layout.item_single_text;
            }
        };
        delegate.registerItemType(R.layout.item_subtitle_text, R.layout.item_subtitle_text)
                .registerItemType(R.layout.item_single_text, R.layout.item_single_text);
        setMultiTypeDelegate(delegate);
    }
    @Override
    protected void convert(BaseViewHolder helper, Object item) {
        if (item instanceof String) {
            helper.setText(R.id.item_tv_text, (String) item);
        } else if (item instanceof CupListResult.VideoBean){
            int emm=helper.getAdapterPosition()-1;
            helper.setText(R.id.item_tv_text, emm+"、"+((CupListResult.VideoBean) item).getVideo_title());
        } else if (item instanceof CupListResult.ExamineListBean){
            helper.setText(R.id.item_tv_text, ((CupListResult.ExamineListBean) item).getEx_title());
        }
    }
}
